package com.ai.networking.websocket.service.util;


import com.ai.networking.websocket.service.entity.WSMessage;
import com.alibaba.fastjson.JSON;

import javax.websocket.DecodeException;
import javax.websocket.Decoder;
import javax.websocket.EndpointConfig;

public class MessageDecoder implements Decoder.Text<WSMessage> {

    @Override
    public WSMessage decode(String s) throws DecodeException {
        return JSON.parseObject(s, WSMessage.class);
    }

    @Override
    public boolean willDecode(String s) {
        return true;
    }

    @Override
    public void init(EndpointConfig endpointConfig) {

    }

    @Override
    public void destroy() {

    }
}